local zhanmeng = fk.CreateSkill({
  name = "pc__zhanmeng",
  tags = {Skill.Switch},
})

zhanmeng:addEffect(fk.CardUsing, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(zhanmeng.name) and target.phase==Player.Play
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if data.card.color == Card.Black then
        local judge
        if player:getSwitchSkillState(zhanmeng.name) == fk.SwitchYin then
           judge= {
            who = player,
            reason = zhanmeng.name,
            pattern = ".|.|Spade,Club",
            }
        else
            judge= {
            who = player,
            reason = zhanmeng.name,
            pattern = ".|.|diamond,Heart",
            }
        end
        room:judge(judge)
        if judge.card.color == data.card.color and player:getSwitchSkillState(zhanmeng.name) == fk.SwitchYin then
            player:drawCards(2,zhanmeng.name)
        elseif judge.card.color ~= data.card.color and player:getSwitchSkillState(zhanmeng.name) == fk.SwitchYang then
            data.toCard = nil
            data:removeAllTargets()
        end
    elseif data.card.color == Card.Red then
        local judge
        if player:getSwitchSkillState(zhanmeng.name) == fk.SwitchYin then
           judge= {
            who = player,
            reason = zhanmeng.name,
            pattern = ".|.|diamond,Heart",
            }
        else
            judge= {
            who = player,
            reason = zhanmeng.name,
            pattern = ".|.|Spade,Club",
            }
        end
        room:judge(judge)
        if judge.card.color == data.card.color and player:getSwitchSkillState(zhanmeng.name) == fk.SwitchYin then
            player:drawCards(2,zhanmeng.name)
        elseif judge.card.color ~= data.card.color and player:getSwitchSkillState(zhanmeng.name) == fk.SwitchYang then
            data.toCard = nil
            data:removeAllTargets()
        end
    else
        local judge = {
        who = player,
        reason = zhanmeng.name,
        pattern = ".",
        }
        room:judge(judge)
        if judge.card.color == data.card.color and player:getSwitchSkillState(zhanmeng.name) == fk.SwitchYin then
            player:drawCards(2,zhanmeng.name)
        elseif judge.card.color ~= data.card.color and player:getSwitchSkillState(zhanmeng.name) == fk.SwitchYang then
            data.toCard = nil
            data:removeAllTargets()
        end
    end
  end,
})



Fk:loadTranslationTable {
["pc__zhanmeng"] = "占梦",
[":pc__zhanmeng"] = "<b>转换技</b>，出牌阶段，当你使用牌时，你可以进行判定，若结果与之颜色①相同，你摸两张牌；②不同，你令之无效。",
["$pc__zhanmeng1"] = "",
["$pc__zhanmeng2"] = "",
}
return zhanmeng